﻿using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Windows.Forms;

namespace Home.MobileSales.Common.Components
{
    public class SelectionColorTextBoxColumn : DataGridTextBoxColumn
    {
        public Color SelectColor { get; set; }
        public string CheckColumn { get; set; }
        public object CheckValue { get; set; }


        protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
        {
            if (CheckColumn != null)
            {
                object value = source.List[rowNum].GetType().GetProperty(CheckColumn).GetValue(source.List[rowNum], null);
                if (value.ToString() == CheckValue.ToString())
                {
                    foreBrush = new SolidBrush(SelectColor);
                }
            }
            base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
        }
    }
}
